/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.ifal.newnews.bd;

import br.edu.ifal.newnews.modelo.Usuario;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author ifal
 */
public class LoginBD {

     public Usuario confirmarLogin(String senha, String email) throws SQLException {
        Connection c = new ConexaoBD().abreConexao();

        String sql = "select * from tbUsuario where senha=?";
        PreparedStatement stmt = c.prepareStatement(sql);

        stmt.setString(1, senha);

        ResultSet rs = stmt.executeQuery();
        Usuario c1 = new Usuario();

        while (rs.next()) {



            c1.setEmail(rs.getString("email"));
            c1.setSenha(rs.getString("senha"));
        }
        rs.close();
        stmt.close();
        c.close();

        return c1;
    }
}
